/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86186
 * Date: 2023-09-06
 * Time: 22:58
 */
public class ThreadDemo5 {
    private static Object locker1 = new Object();
    private static Object locker2 = new Object();
    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            synchronized (locker1) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                synchronized (locker2) {
                    ;
                }
            }
            System.out.println("线程t1 结束");
        });

        Thread t2 = new Thread(() -> {
           synchronized (locker2) {
               try {
                   Thread.sleep(1000);
               } catch (InterruptedException e) {
                   throw new RuntimeException(e);
               }
               synchronized (locker1) {
                   ;
               }
           }
            System.out.println("线程t2 结束");
        });

        t1.start();
        t2.start();
    }
}
